<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/css/style.css" type="text/css" media="all" />
<script src="<?php echo URL::base() ?>media/js/jquery-1.10.1.min.js"></script>

<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/artdialog/skins/default.css" type="text/css" media="all" />
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>	 

<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<style type="text/css">
.table1 thead tr th,.table1 tbody tr td{ text-align:center;}
.lab1{ width:100px; text-align:right; display:inline-block; margin-right:5px;}
</style>

<script type="text/javascript">
	$(document).ready(function(){
		$('.table1 > tbody >tr:odd').css("background-color","#f5f5f5");
			
	})
</script>
<?php 
//;催货单界面
$order_by_sel = array("1"=>"采购时间",
					"2"=>"预交期");

?>

<script type="text/javascript">

$(document).ready(function(){

	$(".expediting_remark").click(function(){
		var ids=$(this).attr("id");
		var leng=ids.length;
		
		var id=ids.substr(18,leng-18);//采购明细
		$.ajax({
			type:'post',
			url:'<?php echo URL::base();?>purchases/expediting/add_expediting_remark',
			dataType:'json',
			data:{'details_id':id},
			async:false,
			success:function(data)
			{
				alert("催货成功");
				window.location.href=window.location.href; 
				window.location.reload; 
				
			},
			error:function()
			{
				alert("error");
			}
			});

		});
	
	$.datepicker.setDefaults({ dateFormat: 'yy-mm-dd' });
	$(".datepicker").datepicker();

	$("#order_by_sel").change(function(event) {
		//$("#sel_form").submit();
	});

	//var order_by_sel=<?php //if(isset($GET)) echo $GET[]?>;
});
</script>

<form action="<?php echo url::base(true)?>purchases/expediting/stockchase" method="get" id="sel_form">

<div style="margin-bottom:10px;">
<span class="lab1">采购时间从: </span>
<input type="text" class="datepicker input-medium" 
value="<?php if(isset($GET['purchaseorder_date_from'])) echo $GET['purchaseorder_date_from']?>"
name="purchaseorder_date_from" readonly="readonly">
到 <input style="margin-right:3px;" type="text" class="datepicker input-medium" 
value="<?php if(isset($GET["purchaseorder_date_to"])) echo $GET["purchaseorder_date_to"]?>"
name="purchaseorder_date_to" readonly="readonly"> </div>

<div style="margin-bottom:10px;">
<span class="lab1">预交期从:</span>
<input type="text" class="datepicker input-medium" name="arrive_date_from"
 value="<?php if(isset($GET["arrive_date_from"])) echo $GET["arrive_date_from"]?>"
readonly="readonly">
到 <input type="text" class="datepicker input-medium" name="arrive_date_to" 
value="<?php if(isset($GET["arrive_date_to"])) echo $GET["arrive_date_to"]?>"
readonly="readonly"> 
</div>

<div style="margin-bottom:10px;">
<span class="lab1">排序:</span>
<select style=" width:164px;" style="margin-right:3px;" id="order_by_sel" name="order_by_sel" class="input-medium">
<?php foreach($order_by_sel as $o_sel => $o_value){?>
<option value="<?php echo $o_sel?>"	
<?php if(isset($GET['order_by_sel']) and $GET['order_by_sel'] == $o_sel){echo("selected");}?>><?php echo $o_value?></option>
<?php }?>
</select>
</div>

<div style="margin-bottom:10px;">
<span class="lab1">是否催货:</span>
<select style=" width:164px;" style="margin-right:3px;"  name="expediting_remark" class="input-medium">
<option value="10">未催货</option>
<option value="20">已催货</option>
</select>
</div>

<div style="margin-bottom:10px;">
<span class="lab1">供应商:</span>
<input style="margin-right:3px;" type="text" class="input-medium" name="supplier_name" value="<?php if(isset($GET['supplier_name'])){echo $GET['supplier_name'];}?>">
</div>

<div style="margin-bottom:10px;">
<span class="lab1">SKU:</span>
<input style="margin-right:3px;" type="text" class="input-medium" name="sku" value="<?php if(isset($GET['sku'])){ echo $GET['sku'];}?>">
</div>

<div style="margin-bottom:10px;">
<span class="lab1">采购员:</span>
<input style="margin-right:3px;" type="text" class="input-medium" name="purchase_id_name" value="<?php if(isset($GET['purchase_id_name'])){ echo $GET['purchase_id_name'];}?>">
<input type="submit" style="margin-left:5px;" class="btn btn-info" value="查询">
</div>

</form>

<?php if($purchase_lists){
	?>
	<div>总共有<?php echo count($purchase_lists)?>条记录</div>
<table class="table table1 table-bordered" style="border-collapse: collapse;">
<thead>
	<tr style=" background-color:#4EA392;color:#fff;">
		<th>SKU</th>
		<th>中文名称</th>
		<th>供应商</th>
		<th>采购时间</th>
		<th>预交期</th>
		<th>采购量</th>
		<th>收货量</th>
		<th>入库量</th>
		<th>采购单号</th>
  		<th>供应商联系方式</th>
  		<th>采购人</th>
  		<th>操作</th>
	</tr></thead><tbody>
<?php foreach ($purchase_lists as $key => $purchases) {?>
	<tr>
		<td>
		<input type="hidden" value="<?php echo $purchases['details_id']?>" id="details_id_<?php echo $purchases['details_id']?>"/>
		<?php echo $purchases['sku']?></td>
		<td><?php echo $purchases['sku_name']?></td>
        <!--根据采购单id去查询-->
		<td><?php /*$vProviderName = Service_warning::get_provider_by_id($purchases['id']);*/
            $vProviderName = Purchase::get_provider_info_by_poid($purchases['id']);
		            echo $vProviderName['vProviderName']?></td>

<!--        <td>--><?php //$vProviderName = Service_warning::get_provider_by_id($purchases['supplier']);
//            echo $vProviderName['vProviderName']?><!--</td>-->

		<td><?php echo $purchases['purchaseorder_date']?></td>
		<td><?php echo $purchases['arrive_date']?></td>
		<td><?php echo $purchases['quantity']?></td>
		<td><?php echo $purchases['recieve_quantity']?></td>
		<td><?php echo $purchases['ware_quantity']?></td>
		<td><?php echo $purchases['purchaseorder_id']?></td>
		<td>
		联系人：<?php echo $vProviderName['vContact']?><br/>
		电话：<?php echo $vProviderName['vPhone']?><br/>
		手机：<?php echo $vProviderName['vMobile']?><br/>
		QQ：<?php echo $vProviderName['vQQ']?><br/>
		旺旺：<?php echo $vProviderName['vwangwang']?><br/>
		</td>
		<td><?php echo ORM::factory('user',$purchases['purchase_id'])->nick;?></td>
		<td> <input type="button" class="expediting_remark" value="<?php if($purchases['expediting_remark']==10){echo '未催货';}else{echo '已催货';}?>"    
		<?php if($purchases['expediting_remark']==20){echo "disabled='disabled'";}?>
		id="expediting_remark_<?php echo $purchases['details_id']?>"/></td>
	</tr>
	<?php }?>
	</tbody>
</table>
<?php ?>
<?php if(isset($pagination)) echo $pagination;?>
<?php }?>
